package com.saxon.servlet;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
//ISO_8859_1
public class requestDemo extends HttpServlet {
    @Override
    protected void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding ("utf-8");
        String username = req.getParameter ("username");
        String[] hobbies = req.getParameterValues ("hobbies");
        System.out.println (Arrays.toString (hobbies));
        String path = this.getServletContext ().getContextPath ();
        resp.sendRedirect (path + "/new.html");//302
        //req.getRequestDispatcher ("/sucess.jsp").forward (req,resp);
        resp.setCharacterEncoding ("utf-8");
    }

    @Override
    protected void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet (req, resp);
    }

}
